/**
 * 
 */
package com.eclipse.org.snms.reminder;

import java.util.Calendar;

import com.eclipse.org.snms.TaskComposite;
import com.eclipse.org.snms.serializer.loadStickyNotes.SerializerConcreteSubject;
import com.eclipse.org.snms.summary.SummarySubjectConcrete;

/**
 * @author dimitri.tiago
 *
 */
public class TestReminder 
{

	public static void main(String[] args) 
	{
		// instantiate summary and serializer objects
		SummarySubjectConcrete summary = new SummarySubjectConcrete();
		SerializerConcreteSubject serializer = new SerializerConcreteSubject();
		
		// instantiate reminder object
		ReminderSubjectConcrete reminder = new ReminderSubjectConcrete(summary, serializer);
		
		/**
		 * 
		 * 
		 
		TaskComposite tasks0 = new TaskComposite();
		TaskComposite tasks1 = new TaskComposite();
		Calendar deadline1 = Calendar.getInstance();
		Calendar deadline2 = Calendar.getInstance();
		
		tasks0.setDeadline(deadline1);
		tasks0.setPriority(1);
		tasks0.setTitle("First Task");
		tasks0.setIsActive(1);
		tasks0.setId(123);
		tasks0.setDescription("this is test for the first task");
		
		tasks1.setDeadline(deadline2);
		tasks1.setPriority(2);		
		tasks1.setTitle("Second Task");		
		tasks1.setIsActive(1);
		tasks1.setId(345);
		tasks1.setDescription("this is test for the second task");
		
		reminder.update(tasks0);
		reminder.update(tasks1);
		
		*/
		
		// instantiate reminder observer test instance
		ReminderObserverTest reminderObserver = new ReminderObserverTest(reminder);
		
		// create Tasks
		Calendar calendar1 = Calendar.getInstance(); // create and initialize calendar1 object
	    calendar1.set(Calendar.YEAR, 2009);
	    calendar1.set(Calendar.MONTH, Calendar.APRIL);
	    calendar1.set(Calendar.DATE, 29);
	    calendar1.set(Calendar.HOUR_OF_DAY, 0);
	    calendar1.set(Calendar.MINUTE, 0);
	    calendar1.set(Calendar.SECOND, 0);
	    calendar1.set(Calendar.MILLISECOND, 0);
		
		Calendar calendar2 = Calendar.getInstance(); // create and initialize calendar2 object
		calendar2.set(Calendar.YEAR, 2007);
	    calendar2.set(Calendar.MONTH, Calendar.APRIL);
	    calendar2.set(Calendar.DATE, 29);
	    calendar2.set(Calendar.HOUR_OF_DAY, 0);
	    calendar2.set(Calendar.MINUTE, 0);
	    calendar2.set(Calendar.SECOND, 0);
	    calendar2.set(Calendar.MILLISECOND, 0);
	    
		TaskComposite task1 = new TaskComposite("TASK1", calendar1, 1, 1); // create tasks (active task)
		task1.setDescription("Finish Project by Friday");
		task1.setId(1);
		
		TaskComposite task2 = new TaskComposite("TASK2", calendar2, 2, 1); // create tasks (expired task)
		task2.setDescription("Finish Report by Sunday");
		task2.setId(2);
			
		// update ReminderSubjectConcrete (add two tasks) 
		reminder.update(task1, 0);
		reminder.update(task2, 0);
		
		// check sticky note deadlines
		while (true)
		{
			// if deadline expired 
			reminder.checkDeadlines();
			
			try
			{
				// sleep 60 seconds
				Thread.sleep(60000);
			}
			catch(InterruptedException e)
			{
				// print stack trace
				e.printStackTrace();
			}
			
			//reminder.printOutlist();
			System.out.println("------------------------------");
		}
	}
}
